<?php

namespace app\controllers\action;

class Student
{
    /**
     * @param $conn \mysqli
     * @return array
     */
    public static function get_self_info(&$conn, $student_id)
    {
        $return = [];
        $stmt = $conn->prepare("SELECT * FROM students where student_id=?");
        $stmt->bind_param("s", $student_id);
        $stmt->execute();
        $result = $stmt->get_result();
        while ($row = ($result->fetch_assoc())) {
            unset($row["password"]);
            $return[] = $row;
        }
        $result->free_result();
        $stmt->close();
        return $return;
    }

    /**
     * @param $conn \mysqli
     * @param $student_id string
     * @return array
     */
    public static function get_self_grade($conn, $student_id)
    {
        $return = [];
        $stmt = $conn->prepare("SELECT * FROM student_grades where student_id=?");
        $stmt->bind_param("s", $student_id);
        $stmt->execute();
        $result = $stmt->get_result();
        while ($row = ($result->fetch_assoc())) {
            $return[] = $row;
        }
        $result->free_result();
        $stmt->close();
        return $return;
    }
}